<?php
/**
 * Created by PhpStorm.
 * User: HHZ
 * Date: 2018/11/21
 * Time: 19:12
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Biz\model\TradeMsg as mTradeMsg;
use Doraemon\cache\MsgLastMsg;

$sql = "SELECT * from (select * from  `trade_msg`   ORDER BY send_time DESC ) as trade GROUP BY to_uid ";

$list = mTradeMsg::query($sql)->fetchAll();

foreach ($list as $value) {

    $content = '【' . $value['title'] . '】' .$value['detail'];
    $result = MsgLastMsg::setLastMsg($value["to_uid"], MsgLastMsg::TYPE_TRADE_MSG, json_encode(['addtime' => time(), 'message' => $content]));
    if($result) {
        var_dump('用户  id  '.$value['to_uid'].'数据同步完成');
    }
}

